package main

import (
	"fmt"
)

func huiwen() {
	s := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28}
	max_cap := 5
	_len := len(s)
	_groupNumber := _len / max_cap
	if _len%max_cap != 0 {
		max_cap++
	}
	// fmt.Println(_len, max_cap, _groupNumber)
	result := make([][]int, _groupNumber, max_cap)
	// var result [][]int
	// fmt.Printf("%T %v行 每行最多%v列", result, len(result), len(result[0]))

	// var group []int
	var grap int
	for i := 0; i < _groupNumber; i++ {
		// group = []int{}
		grap = i
		result[i] = append(result[i], s[i])
		for {
			grap += 2*_groupNumber - 1 - 2*i
			if grap >= _len {
				break
			}
			result[i] = append(result[i], s[grap])

			grap += 2*i + 1
			if grap >= _len {
				break
			}
			result[i] = append(result[i], s[grap])
		}
		// fmt.Println(group)
		// result = append(result, group)
	}

	// index := 0
	// for i := 0; i < max_cap; i += 2 {
	// 	var j int
	// 	for j = 0; j < _groupNumber; j++ {
	// 		if index >= _len {
	// 			break
	// 		}
	// 		result[i][j] = s[index]
	// 		index++
	// 	}
	// 	if i >= max_cap {
	// 		break
	// 	}
	// 	for j = _groupNumber - 1; j >= 0; j-- {
	// 		if index >= _len {
	// 			break
	// 		}
	// 		result[i+1][j] = s[index]
	// 		index++
	// 	}
	// }

	for _, itm := range result {
		fmt.Println(itm)
	}
}

func Amain() {
	for i := 1; i <= 9; i++ {
		for j := 1; j <= i; j++ {
			fmt.Printf("%vx%v=%2v ", i, j, i*j)
		}
		fmt.Printf("\n")
	}
	huiwen()

	var n = 1
	switch n {
	case 1:
		fmt.Println("一阳复始")
		fallthrough // 了解但是不要使用
	case 2:
		fmt.Println("双喜临门")
	case 3:
		fmt.Println("三羊开泰")
	case 4:
		fmt.Println("四季发财")
	case 5:
		fmt.Println("五福临门")
	default:
		fmt.Println("恭喜发财")
	}
}
